package com.lagou.ipersistence.scripting.defaults;

import com.lagou.ipersistence.builder.SqlSourceBuilder;
import com.lagou.ipersistence.mapping.BoundSql;
import com.lagou.ipersistence.mapping.SqlSource;
import com.lagou.ipersistence.session.Configuration;

import java.util.HashMap;

/**
 * @author Yan Jiahong
 * Created on 2020/11/16
 */
public class RawSqlSource implements SqlSource {
    private final SqlSource sqlSource;

    public RawSqlSource(Configuration configuration, String sql, Class<?> parameterType) {
        SqlSourceBuilder sqlSourceBuilder = new SqlSourceBuilder(configuration);
        Class<?> clazz  = parameterType== null ? Object.class : parameterType;
        sqlSource = sqlSourceBuilder.parse(sql, clazz);
    }

    @Override
    public BoundSql getBoundSql(Object parameterObject) {
        return sqlSource.getBoundSql(parameterObject);
    }
}
